//
//  YDOAAcuteThingsCell.swift
//  YDOAProduct
//
//  Created by 占益民 on 2017/11/9.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit

class YDOAAcuteThingsCell: UITableViewCell {

    
    @IBOutlet weak internal var btnBg: UIView!
    @IBOutlet weak internal var refuseBtn: UIButton!
    @IBOutlet weak internal var passBtn: UIButton!
    @IBOutlet weak internal var nameLb: UILabel!
    @IBOutlet weak var lineLab: UILabel!
    
    @IBOutlet weak internal var countLb: UILabel!
    @IBOutlet weak internal var thingsLb: UILabel!
    @IBOutlet weak internal var applyTimeLb: UILabel!
    @IBOutlet weak internal var depatmentLb: UILabel!
    @IBOutlet weak var remarkLb: UILabel!
    
    @IBOutlet weak var refuseResonLb: UILabel!//拒绝理由
    @IBOutlet weak var refusePersion: UILabel!//拒绝人
    
    
    
    var refuseCallBack: ((_ id: Int) -> Swift.Void)? = nil
    var passCallBack: ((_ id: Int) -> Swift.Void)? = nil
    
    
    
    var model : YDOAAcuteApporvalModel!{
        didSet{
            guard let model = model else {
                return;
            }
            
            nameLb.text = "申请人: \(model.apply_person!)"
            countLb.text = "申请数量: \(model.apply_time!)"
            thingsLb.text = "申请物品: \(model.goods_name!)"
            applyTimeLb.text = "申请时间: \(model.apply_time!)"
            depatmentLb.text = "申请部门: \( model.department!)"
            remarkLb.text = "备注:\(model.remark!)"
            
            if model.status == 2 {
                refuseResonLb.text = "拒绝理由: \(model.refuse_reson ?? "")"
                refusePersion.text = "拒绝人: \(model.ctr_id ?? 0)"
                refusePersion.isHidden = false
                refuseResonLb.isHidden = false
                lineLab.isHidden = true
                refuseBtn.isHidden = true
                passBtn.isHidden = true
            }else if model.status == 1{
                refusePersion.isHidden = true
                refuseResonLb.isHidden = true
                refuseBtn.isHidden = true
                passBtn.isHidden = true
            }else{
                refuseBtn.isHidden = false
                passBtn.isHidden = false
            }
            
            
        }
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    /// 拒绝按钮点击
    ///
    /// - Parameter sender:闭包回调
    @IBAction func refuseBtnClick(_ sender: Any) {
        if refuseCallBack != nil {
            refuseCallBack!(model.id!)
        }
    }
    
    /// 通过按钮点击
    ///
    /// - Parameter sender:闭包回调
    @IBAction func passBtnClick(_ sender: Any) {
        if refuseCallBack != nil {
            passCallBack!(model.id!)
        }
    }
}
